package cn.iocoder.yudao.module.design.dal.mysql.flowmd;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.flowmd.vo.FlowMdExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.flowmd.vo.FlowMdPageReqVO;
import cn.iocoder.yudao.module.design.dal.dataobject.flowmd.FlowMdDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 流程模板 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FlowMdMapper extends BaseMapperX<FlowMdDO> {

    default PageResult<FlowMdDO> selectPage(FlowMdPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FlowMdDO>()
                .likeIfPresent(FlowMdDO::getFlowName, reqVO.getFlowName())
                .eqIfPresent(FlowMdDO::getFlowCd, reqVO.getFlowCd())
                .eqIfPresent(FlowMdDO::getFlowDtlCd, reqVO.getFlowDtlCd())
                .likeIfPresent(FlowMdDO::getChildren, reqVO.getChildren())
                .eqIfPresent(FlowMdDO::getIsMainCd, reqVO.getIsMainCd())
                .eqIfPresent(FlowMdDO::getStatusCd, reqVO.getStatusCd())
                .orderByDesc(FlowMdDO::getId));
    }

    default List<FlowMdDO> selectList(FlowMdExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FlowMdDO>()
                .likeIfPresent(FlowMdDO::getFlowName, reqVO.getFlowName())
                .eqIfPresent(FlowMdDO::getFlowCd, reqVO.getFlowCd())
                .eqIfPresent(FlowMdDO::getFlowDtlCd, reqVO.getFlowDtlCd())
                .likeIfPresent(FlowMdDO::getChildren, reqVO.getChildren())
                .eqIfPresent(FlowMdDO::getIsMainCd, reqVO.getIsMainCd())
                .eqIfPresent(FlowMdDO::getStatusCd, reqVO.getStatusCd())
                .orderByDesc(FlowMdDO::getId));
    }

}
